Map | NOSTRA Developer

Class : Map

Description

The Map class creates a container and required DOM structure for adding layers, graphics. Typically, a map is added to a page using a DIV. The map's width and height are initialized to those of the DIV container.

Constructors

NameSummary
Map (container, options?)Creates a new map inside of the given HTML container, which is often a DIV element.

Method

NameReturn TypeSummary
addLayer(layer)NoneAdds Basemap & Special Layer to the map.
centerAndZoom(latitude, longitude, level)NoneSet the center and zoom level on the view.
disableDoubleClickZoom()NoneDisallows double clicking on a map to zoom in a level and center the map.
getBoundary()BoundaryGet map extent.
getLayerIds()String[]Returns an all layers of a map.
getLevel()IntegerGets the current level of detail for the map.
getLayerDetail()String[]Gets layer detail such as; default level, default zoom, sort index of layer.
getScale()IntegerGet the current scale of the map for display.
getStyle()ObjectReturns an object that contains the current style information for the layer.
panTo(latitude, longitude)NoneCenters the map based on map coordinates as the center point.
print(width, height, dpi, callback)NoneExport the map including visible layers and visible graphics to PNG image.
removeAllLayers()NoneRemoves all layers from the map.
removeLayer(layerId)NoneRemoves the specified layer from the map.
setExtent(path)NoneSet the extent of the map.
setFloorPosition(valign, halign, margin)NoneSet floor UI position.
setLogoPosition(valign, halign, margin)NoneSet logo position.
setScale(scale)NoneSet extent map scale. For example: 1000, 4000
setScalebarPosition(valign, halign, margin)NoneSet scale position.
setSliderPosition(valign, halign, margin)NoneSet slider position.
setStyle(styleObject)NoneChanges the style properties used to render the layers.
setVisibleScalebar(visible)NoneShow or hide Scale bar.
setVisibleSlider(visible)NoneShow or hide map zoom in/ zoom out element.
zoomBoundary(boundary)NoneZoom to specified extent.
zoomLevel(level)NoneSets and zoom the map to the specified level.
zoomToNetworkResult(solveResult)NoneZoom to the network result.
zoomToRouteLine(direction)NoneZoom to the route result.
zoomToRouteNode(direction, index)NoneZoom to each node of route.

Event

NameDetails
onClickFires event when single clicks on basemap.
onDoubleClickFires event when double clicks on basemap.
onLayerRemoveComplateFires event when layer has been removed.
onLayerAddCompleteFires event when layer has been added to basemap.
onLoadFires when the first or base layer has been successfully added to the map.
onPanFires during the pan process.
onZoomFires during the zoom process.

Constructor Details

Map(container, option?)

NameRequireDetails
containerRequireDIV id element for the referencing map.
optionsOptionalOptional parameters. See options list.

Options Properties

NameTypeDetails
idStringMap object ID
scalebarBooleanIf true, map scale bar will be visible.
sliderBooleanIf true, map zoom in/zoom out element will be visible.
levelIntegerZoom level.
latdoubleLatitude in decimal degree.
londoubleLongitude in decimal degree.
countryStringCountry code for display basemap. The country codes are support as follow.

  • • TH - Thailand
  • • SG - Singapore
  • • MY - Malaysia
  • • BN - Brunei
  • • VN - Vietnam
  • • PH - Philippines
  • • ID - Indonesia
  • • MM - Myanmar
  • • LA - Laos
  • • KH - Cambodia

Method Details

addLayer(layer)

Name RequireDetails
<nostra.maps.Layers> layerRequireNOSTRA Basemap and Special layer.

centerAndZoom(latitude, longitude, level)

Name RequireDetails
<Double> latitudeRequireLatitude in decimal degree.
<Double> longitudeRequireLongitude in decimal degree
<Integer> levelRequireZoom level.

panTo(latitude, longitude)

Name RequireDetails
<Double> latitudeRequireLatitude in decimal degree.
<Double> longitudeRequireLongitude in decimal degree

print(width, height, dpi, callback)

Name RequireDetails
<Integer> widthRequireExport image width.
<Integer> heightRequireExport image height.
<Integer> ppiRequirePPI stands for Pixels Per Inch, Measurements of the pixel density (resolution) of export image.
<Functions> callbackRequireThe function to call when the method has completed with the resulting export image url.

removeLayer(layerId)

Name RequireDetails
<String> layerIdRequireLayer ID that can get by GetLayer method.

setExtent(path)

Name RequireDetails
<String[][]> pathRequireTwo dimension array of latitude and longitude

setFloorPosition(valign, halign, margin)

Name RequireDetails
<String> valignRequireVertical position of floor UI. Valid values are: 'TOP', 'BOTTOM'.
<String> halignRequireHorizontal position of floor UI. Valid values are: 'LEFT', 'CENTER', 'RIGHT'.
<Integer> marginRequireMargin of floor UI [left, top, right, bottom]. Example: [5,10,15,5].

setLogoPosition(valign, halign, margin)

Name RequireDetails
<String> valignRequireVertical position of Logo. Valid values are: 'TOP', 'BOTTOM'.
<String> halignRequireHorizontal position of Logo. Valid values are: 'LEFT', 'CENTER', 'RIGHT'.
<Integer> marginRequireMargin of Logo [left, top, right, bottom]. Example: [5,10,15,5].

setScale(scale)

Name RequireDetails
<Integer> scaleRequireA map scale value greater than 0.

setScalebarPosition(valign, halign, margin)

Name RequireDetails
<String> valignRequireVertical position of scalebar. Valid values are: 'TOP', 'BOTTOM'.
<String> halignRequireHorizontal position of scalebar. Valid values are: 'LEFT', 'CENTER', 'RIGHT'.
<Integer> marginRequireMargin of scalebar [left, top, right, bottom]. Example: [5,10,15,5].

setSliderPosition(valign, halign, margin)

Name RequireDetails
<String> valignRequireVertical position of slider. Valid values are: 'TOP', 'BOTTOM'.
<String> halignRequireHorizontal position of slider. Valid values are: 'LEFT', 'CENTER', 'RIGHT'.
<Integer> marginRequireMargin of slider [left, top, right, bottom]. Example: [5,10,15,5].

setVisibleScalebar(visible)

Name RequireDetails
<Boolean> visibleRequireIf true, map scale bar will be visible.

setVisibleSlider(visible)

Name RequireDetails
<Boolean> visibleRequireIf true, map zoom in/zoom out element will be visible.

zoomBoundary(boundary)

Name RequireDetails
<Boundary> boundaryRequireJSON object contain geometry information.

zoomLevel(level)

Name RequireDetails
<Integer> levelRequireZoom level.

zoomToNetworkResult(solveResult)

Name RequireDetails
<SolveResult> solveResultRequireJSON object contain returned result from network analysis; for example service area, closest facility.

zoomToRouteLine(direction, index)

Name RequireDetails
<Direction> directionRequireJSON object contain returned route result.
<Integer> indexRequireIndex node of direction.

zoomToRouteNode(direction)

Name RequireDetails
<Direction> directionRequireJSON object contain returned route result.